#include "SceneSerializer.h"
#include <SECore/Ecs/Scene.h>
#include <yaml-cpp/yaml.h>
#include <SESerializeYAML/Util.h>
#include <SESerializeYAML/ActorSerializer.h>


namespace SEngine
{
    std::string Serializer<Scene>::Serialize(Scene &object)
    {
        YAML::Node node;
        for (auto & actor : object.m_actors) {
            if (!actor->GetParent()) {
                node["Actors"].push_back(YAML::Load(actor->Serialize()));
            }
        }
        return YAMLNodeToString(node);
    }

    void Serializer<Scene>::Deserialize(const std::string& str, Scene & object)
    {
        YAML::Node node = YAML::Load(str);
        for (auto actorNode : node["Actors"]) {
            auto & actor = object.CreateActor();
            actor.Deserialize(YAMLNodeToString(actorNode));
        }
    }

    
} // namespace SEngine

